package com.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.FunctionDao;
import com.domain.Function;
import com.domain.User;
import com.service.FunctionService;

@Service(value="functionService")
@Transactional
public class FunctionServiceImpl implements FunctionService{
	@Resource(name="functionDao")
	private FunctionDao funtionDao;

	@Override
	public List<Function> findAllFunction() {
		return funtionDao.findAll();
	}

	@Override
	public List<Function> findMenu(User user) {
		List<Function> list=null;
		if(user.getUsername().equals("admin")){
			list = funtionDao.findAll();
		}else{
			list=funtionDao.findByUserId(user.getId());
		}
		return list;
	}

	
}
